from Project1.db.Global import engine
from sqlalchemy.orm import sessionmaker
from Project1.entity.Tables import User



def addUser():
    # 创建会话
    Session = sessionmaker(bind=engine)
    session = Session()
    # 创建用户
    user = User(name='John Doe',age=24,email='john@example.com')
    session.add(user)
    session.commit()

def showUsers():
    # 创建会话
    Session = sessionmaker(bind=engine)
    session = Session()
    # 查询用户
    users = session.query(User).all()
    for user in users:
        print(user.name,user.age,user.email)